package com.example.smartplay.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.smartplay.entity.Activity;
import com.example.smartplay.entity.Activity;
import com.example.smartplay.entity.Notice;
import com.example.smartplay.entity.Result;
import com.example.smartplay.mapper.ActivityMapper;
import com.example.smartplay.mapper.ActivityMapper;
import com.example.smartplay.service.ActivityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2024-07-11
 */
@Service
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private ActivityMapper ActivityMapper;
    //查询全部活动
    @Override
    public List<Activity> list() {
        return ActivityMapper.list();
    }
    //新增活动
    @Override
    public void add(Activity activity) {
        ActivityMapper.insert(activity);
    }
    //删除活动
    @Override
    public void delete(List<Integer> ids) {
        ActivityMapper.deleteBatchIds(ids);
    }
    //根据id查询活动
    @Override
    public Activity find(Integer id) {
        return ActivityMapper.selectById(id);
    }
    //修改活动
    @Override
    public void update2(Activity activity) {
        ActivityMapper.updateById(activity);
    }
    //分页查询活动
    @Override
    public Result getactivity(Integer pageNum, Integer pageSize) {
        Page<Activity> page = new Page<>(pageNum, pageSize);
        return Result.success(ActivityMapper.selectPage(page, null));
    }
}
